package com.cmdi.mq.controller;//package com.cmdi.controller;
//
//import com.cmdi.domain.LoginResult;
//import com.cmdi.model.R;
//import com.cmdi.service.SysLoginService;
//import com.cmdi.service.SysRoleService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.security.access.prepost.PreAuthorize;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.servlet.http.HttpServletRequest;
//import java.security.Principal;
//
///**
// * @Description: java类作用描述
// * @Author: gaozb
// */
//@RestController
//@Api(tags = "角色管理")
//public class SysRoleController {
//    @Autowired
//    private SysRoleService sysRoleService;
//
//    @PostMapping("/getroles")
//    @ApiOperation("获取所有角色")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "username", value = "用户名称"),
//            @ApiImplicitParam(name = "password", value = "用户的密码"),
//    })
//    //@SysLog("用户登录")
//    public LoginResult login(@RequestParam(required = true) String username,
//                             @RequestParam(required = true) String password) {
//
//        return sysLoginService.login(username, password);
//    }
//
//    @PostMapping("/refreshtoken")
//    @ApiOperation("token续签，务必在token失效前续签")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "refreshtoken", value = "token续签")
//    })
//    //@SysLog("token续签")
//    public LoginResult refreshtoken(@RequestParam(required = true) String refreshtoken) {
//
//        return sysLoginService.refreshToken(refreshtoken);
//    }
//
//    @GetMapping("/out")
//    public R logout(HttpServletRequest request, Principal principal) {
//        if(principal != null) {
//            String authorization = request.getHeader("Authorization");
//            String token = authorization.replaceAll("bearer ", "");
//            String name = principal.getName();
//            String key = "minecmdi:" + name + "." + token;
//            //System.out.println(key);
//            if(redisTemplate.hasKey(key)) {
//                if(redisTemplate.delete(key)) {
//                    return R.ok(null, "logout ok");
//                }
//            } else {
//                return R.ok(null,"not login");
//            }
//        } else {
//            return R.ok(null,"not login");
//        }
//        return R.ok(null,"not login");
//    }
//
//    @GetMapping("/test1")
//    @PreAuthorize("hasAuthority('cash_withdraw_audit_1')")
//    public R<String> test1() {
//        return R.ok("123");
//    }
//
//    @GetMapping("/test2")
//    @PreAuthorize("hasAuthority('cash_withdraw_audit_888')")
//    public R<String> test2() {
//        return R.ok("123");
//    }
//
//}